/*
 * @Author: ZRX
 * @Date: 2024-01-08 14:17:35
 * @LastEditors: sueRimn
 * @LastEditTime: 2024-01-11 11:17:04
 * @Descripttion:
 * @version:
 */
import { Login } from "@/api/interface/index";
import { PORT1 } from "@/api/config/servicePort";
import { Menu } from "@/api/interface/index";

import { AES128 } from "./encryption";
import http from "@/api";

/**
 * @name 登录模块
 */
// 用户登录

export const loginApi = (params: Login.ReqLoginForm) => {
  return http.post<Login.ResLogin>(PORT1 + `/login/index `,{login:AES128(JSON.stringify(params))}, { loading: false }); // 正常 post json 请求  ==>  application/json
  // return http.post<Login.ResLogin>(PORT1 + `/login`, params, { loading: false }); // 控制当前请求不显示 loading
  // return http.post<Login.ResLogin>(PORT1 + `/login`, {}, { params }); // post 请求携带 query 参数  ==>  ?username=admin&password=123456
  // return http.post<Login.ResLogin>(PORT1 + `/login`, qs.stringify(params)); // post 请求携带表单参数  ==>  application/x-www-form-urlencoded
  // return http.get<Login.ResLogin>(PORT1 + `/login?${qs.stringify(params, { arrayFormat: "repeat" })}`); // get 请求可以携带数组等复杂参数
};

// 获取菜单列表
export const getAuthMenuListApi = (id:string) => {
	let idStr:string = '';
	if(id){
		idStr = `?uid=${id}`
	}
  return http.get<Menu.MenuOptions[]>(PORT1 +`/sys/menu/list?${idStr}`, {},{ loading: false });


};

//获取最近访问/已收藏的菜单目录
export const getCollectMenuListApi = () => {
  return http.get<Collect.MenuOptions[]>(PORT1 +`/sys/menu/fav-and-visited-list`, {}, { loading: false });

};



// 用户退出登录
// export const logoutApi = () => {
//   return http.post(PORT1 + `/logout`);
// };
